﻿@model S4Store.Models.FinancialKpi.IndexModel
 @{
     Layout = null;
     ViewBag.Title = "Index";
}

<div style="height:100%;width:100%; overflow:auto" class="verticalSplitContainer">
@Html.Action("StoreList", "Common", new { action = "Index", controller = "FinancialKpi" })
<div style="width:100%; overflow:auto" ratio="*">

<table   style="border-collapse:collapse;" class="reporttable2">
    <tr>
        <th>年</th>
        <th colspan="2">月初计划</th>
        <th colspan="31">
        <div style="float:left">每日数据</div>
        <div style="float:right">
            <div class="indexred">红色为未录入</div>
            <div class="indexyellow">黄色为未确认</div>
            <div class="indexgreen">绿色为已确认</div>
        </div>
        </th>
    </tr>
    @for (int y = 0; y < 2; y++)
    {
        int mtotal = 12;
        if (y == 0)
        {
            mtotal = DateTime.Now.Month;
        }
        for (int m = mtotal; m > 0; m--)
        {
            DateTime dt = DateTimeExtend.MonthLastOrNow(DateTime.Now.AddYears(y * -1).Year, m, DateTime.Now.Day);
            //DateTime dt = new DateTime(DateTime.Now.AddYears(y * -1).Year, m, DateTime.Now.Day).MonthLastOrNow();
    <tr>
        @if (m == mtotal)
        {
        <td rowspan="@mtotal" >@DateTime.Now.AddYears(y * -1).Year</td>
        }
        @Html.Action("MonthTd", new { y = DateTime.Now.AddYears(y * -1).Year, m = m })
        @for (int d = 1; d <= 31; d++)
        {
            if(d>dt.Day){
                <td></td>
            }else{
                var status=Model.GetDayStatus(DateTime.Now.AddYears(y * -1).Year,m,d);
            
                if (status == null)
                {
            <td   class="day bgred"><a width="980px" href="@Url.Action("InputFinancialKpiDayData", new {  StoreId = Model.StoreId,y = DateTime.Now.AddYears(y * -1).Year, m = m, d = d })" target="dialog" backtype="html" refreshonclose="true" title="录入@(m)月@(d)日数据">@d</a></td>
                }
                else if (status == S4Store.Domain.DataConfirmStatus.Confirmed)
                {
            <td class="day bggreen"><a width="980px" href="@Url.Action("InputFinancialKpiDayData", new {  StoreId = Model.StoreId,y = DateTime.Now.AddYears(y * -1).Year, m = m, d = d })" target="dialog" backtype="html" refreshonclose="true" title="查看@(m)月@(d)日数据">@d</a></td>
                }
                else
                {
                <td   class="day bgyellow"><a width="980px" href="@Url.Action("InputFinancialKpiDayData", new { StoreId = Model.StoreId, y = DateTime.Now.AddYears(y * -1).Year, m = m, d = d })" target="dialog" backtype="html" refreshonclose="true" title="录入@(m)月@(d)日数据">@d</a></td>
                    
                }
            }
        }
    </tr>   
        }
    }
</table>

</div>
</div>

